package week_three_day03.json;

import org.json.JSONArray;
import org.json.JSONObject;

public class OrgJsonTest {
	public static void main(String[] args) {
		JSONObject jso = new JSONObject();
		JSONObject addr = new JSONObject();
		addr.put("id", "a1");
		addr.put("name", "king");
		
		
		jso.put("id", "c1");
		jso.put("addr", addr);
		jso.put("name", "evan");
		jso.put("age", 23);
		jso.put("salary", 34.56);
		jso.put("sex", true);
		jso.put("favs", new String[]{"basket","swim"});
		
		String jsonString = jso.toString();
		
		JSONObject jso1 = new JSONObject(jsonString);
		
		System.out.println(jso1.get("name"));
		JSONArray favs = (JSONArray)jso1.get("favs");
		for(int i=0;i<favs.length();i++){
			System.out.println(favs.get(i));
		}
		
		System.out.println(jso.toString());
	}
}
